import { ref, onMounted, onUnmounted } from "vue";

//实现鼠标打点的方法
export default function() {
    let x = ref(0);
    let y = ref(0);

    function useMouse(e) {
        x.value = e.pageX;
        y.value = e.pageY;
    }

    onMounted(() => window.addEventListener("mousemove", useMouse));
    onUnmounted(() => window.removeEventListener("mousemove", useMouse));

    return { x, y }
}

